
import BaseStorage from "./BaseStorage";
import { isNull } from "../tools/Define";

export default class LocalValue extends BaseStorage {



    protected loadValue() {

        let localValue = this.getStorage();
        if (isNull(localValue)) {
            this.setValue(this.initValue);
            return true
        } else {
            this.value = localValue;
            return false
        }

    }

    updateValue(value: number) {
        let data = this.value + value;
        if (data < 0) {
            data = 0;
        }
        this.setValue(data)
    }

}
